import { FlowStatus } from './Enums';
import { subgame001 as _ } from './UIConfig';
import { BaseUIRoot } from '../../scripts/libs/ui/BaseUIRoot';
import { _decorator, color } from 'cc';
import { game001 } from './Game001Manager';
const { ccclass, property } = _decorator;

export namespace subgame001 {

    const config = new Map<FlowStatus, Set<_.PanelKey>>([
        [FlowStatus.Empty, new Set()],
        [FlowStatus.Main, new Set([
            _.PanelKey.MainPanel
        ])],
    ]);

    @ccclass('UIRoot')
    export class UIRoot extends BaseUIRoot {

        get logColorOverride() { return color().fromHEX('#DDDDEE') };

        getPanelKeyEnum() {
            return _.PanelKey as any;
        }

        willBind() {
            super.willBind();
            game001.uiRoot = this;
        }

        useObserves() {
            return [
                ...super.useObserves(),
                game001.flowStatus.subscribePairWise(pair => {
                    this.statusChangedWithConfig(pair, config);
                }),
                game001.loadingEnabled.subscribe(enabled => enabled ? this.openPanel(_.PanelKey.LoadingPanel as any).subscribe() : this.closePanel(_.PanelKey.LoadingPanel as any).subscribe()),
            ];
        }

    }

}